<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Blogger_Edit extends Controller_DefaultTemplate{

public function action_id()
{
	$id = $this->request->param('id');
	$blog = ORM::factory('blog')
		->where('id', '=', $id)
		->and_where('user_id', '=', Auth::instance()->get_user()->id)
		->find();
	if ($blog->loaded())
	{
		if ($_POST)
		{
			$blog->values(array(
				'name' => arr::get($_POST, 'blog_name'),
				'url_feed' => arr::get($_POST, 'blog_url'),
				'description' => arr::get($_POST, 'descriptions'),
				'update_time' => time(),
				'status'      => 'modify'
				));
			$blog->save();
		}
		else
		{
			$this->template->content = View::factory('blogger/edit');
			$this->template->content->set('blog', $blog);
			return;
		}
	}
	$this->request->redirect('/blogger/dashboard');
}

public function action_update()
{
	if ($_POST)
    {
		$id = arr::get($_POST, 'blog_id');
		$blog = ORM::factory('blog')->where('id', '=', $id)->find();
		
	}
}

/**
* Initialize properties before running the controller methods (actions),
* so they are available to our action.
*/
public function before()
{
	// Run anything that need ot run before this.
	parent::before();

	if (!Auth::instance()->logged_in())
	{
		$this->request->redirect('/user/login');
	}
}

}






